/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.service.impl;

import com.icinfo.cloud.provider.punish.config.model.ConfigAppAuthorizationRecord;
import com.icinfo.cloud.provider.punish.mapper.ConfigAppAuthorizationRecordMapper;
import com.icinfo.cloud.provider.punish.service.IConfigAppAuthorizationRecordService;
import com.icinfo.framework.core.service.support.MyBatisServiceSupport;
import com.icinfo.framework.mybatis.mapper.entity.Example;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述: 应用接入授权记录表 config_app_authorization_record 对应的Service接口实现类.<br>
 *
 * @author framework generator
 * @date 2022年08月16日
 */
@Slf4j
@Service
public class ConfigAppAuthorizationRecordServiceImpl extends MyBatisServiceSupport implements IConfigAppAuthorizationRecordService {

    @Resource
    private ConfigAppAuthorizationRecordMapper configAppAuthorizationRecordMapper;

    @Override
    public String getAppKeyByAppId(String appId) {
        //查询应授权记录
        Example query = new Example(ConfigAppAuthorizationRecord.class);
        query.createCriteria().andEqualTo("appId", appId);
        List<ConfigAppAuthorizationRecord> configAppAuthorizationRecords = configAppAuthorizationRecordMapper.selectByExample(query);
        if (!ObjectUtils.isEmpty(configAppAuthorizationRecords)) {
            return configAppAuthorizationRecords.get(0).getAppKey();
        }
        return null;
    }
}